/* The link: http://poj.org/problem?id=1067
 * I just utilize the implementation of the algorithms displayed int the Disucess of this problem
 */

#include <iostream>
#include <math.h>

using namespace std;

int main(int argc, char *argv[])
{
	// The number of stones 
	int a, b;
	while (cin >> a >> b) {
		// The value correponding to the values of odd conditions
		int aj, bj;

		// Store the larger one to a and the other one to b
		int temp = a;
		a = min(a, b);
		b = max(temp, b);		

		int j = floor((sqrt(5 * 1.0) - 1) / 2 * a); 
		aj = floor((sqrt(5 * 1.0) + 1) / 2 * j);
		if (a == aj) {
			aj = a;
			bj = aj + j;
		} else {
			aj = floor((sqrt(5 * 1.0) + 1) / 2 * (j + 1));
			bj = aj + j + 1;
		}

		if (a == aj && b == bj)
			cout << 0 << endl;
		else
			cout << 1 << endl;
	}
	return 0;
}